package demo.bocweb.com.sdk.util;

import android.content.Context;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Interceptor;
import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
import com.alibaba.android.arouter.facade.template.IInterceptor;
import com.alibaba.android.arouter.launcher.ARouter;

import demo.bocweb.com.sdk.config.ARoutConfig;
import demo.bocweb.com.sdk.config.AppConfig;

/**
 * 用户是否登录的拦截
 * Created by zhelun on 2018/2/5.
 */
@Interceptor(priority = 1)
public class LoginInterceptor implements IInterceptor {
    @Override
    public void process(Postcard postcard, InterceptorCallback callback) {
        if (SP.contains(AppConfig.Authorization)) {
            callback.onContinue(postcard);
        } else {
            callback.onInterrupt(null);
            ARouter.getInstance().build(ARoutConfig.loginPath).greenChannel().navigation();
        }
    }

    @Override
    public void init(Context context) {

    }
}
